﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL;
namespace ERP.Page
{
    public partial class Import_Order : System.Web.UI.Page
    {
        #region[Define]
        private DataTable dtGetBranchImport;
        private DataTable dtGetWarehouseImport;
        private DataTable dtGetRoomImport;
        private Import_BLL clsImport = new Import_BLL();
        #endregion

        #region[Controller]
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetBranchImport();
                GetWarehouseImport(int.Parse(drChiNhanh.SelectedValue.ToString()));
                GetRoomImport(int.Parse(drChonKho.SelectedValue.ToString()));
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            OpenDialog("#importorder");
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }
        protected void btnReload_Click(object sender, EventArgs e)
        {

        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
 
        }
        protected void btnExcel_Click(object sender, EventArgs e)
        {

        }
        //------------Popup---------
        protected void btnSave_Click(object sender, EventArgs e)
        {
 
        }
        protected void btnReloadPopup_Click(object sender, EventArgs e)
        {

        }
        protected void btnAddMaterials_Popup_Click(object sender, EventArgs e)
        {
 
        }
        //--------Btn-Materials------
        protected void btnSearchUC_Click(object sender, EventArgs e)
        {
        }
        protected void btnReloadUC_Click(object sender, EventArgs e)
        {
        }
        protected void btnAddMaterials_Click(object sender, EventArgs e)
        {

        }
        //---------Dropdownlist----------
        protected void drNguoiLapPhieu_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
        protected void drChiNhanh_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        protected void drChonKho_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        #endregion

        #region[Method]
        protected void GetBranchImport()
        {
            dtGetBranchImport = clsImport.GetBranch_Import(1);
            if (dtGetBranchImport != null && dtGetBranchImport.Rows.Count > 0)
            {
                drChiNhanh.DataSource = dtGetBranchImport;
                drChiNhanh.DataTextField = "Branch_Name";
                drChiNhanh.DataValueField = "Branch_Id";
                drChiNhanh.DataBind();
            }
        }
        protected void GetWarehouseImport(int id)
        {
            dtGetWarehouseImport = clsImport.GetWarehouse_Import(id, 1);
            if (dtGetWarehouseImport != null && dtGetWarehouseImport.Rows.Count > 0)
            {
                drChonKho.DataSource = dtGetWarehouseImport;
                drChonKho.DataTextField = "Warehouse_Name";
                drChonKho.DataValueField = "Warehouse_Id";
                drChonKho.DataBind();
            }
        }
        protected void GetRoomImport(int id)
        {
            dtGetRoomImport = clsImport.GetRoom_Import(id, 1);
            if (dtGetRoomImport != null && dtGetRoomImport.Rows.Count > 0)
            {
                drPhongChua.DataSource = dtGetRoomImport;
                drPhongChua.DataTextField = "Room_Name";
                drPhongChua.DataValueField = "Room_Id";
                drPhongChua.DataBind();
            }
        }
        #endregion

        #region[OpenDialog]
        private void OpenDialog(string dialogId)
        {
            var sb = new StringBuilder();
            sb.Append("$('" + dialogId + "').dialog('open');");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(),
                "scriptKey", sb.ToString(), true);
        }
        private void CloseDialog(string dialogId)
        {
            var sb = new StringBuilder();
            sb.Append("$('" + dialogId + "').dialog('close');");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(),
                "scriptKey", sb.ToString(), true);
        }
        #endregion
    }
}